package noodfun

import (
	"fmt"
	"runtime/debug"
)

// TryGo 协程池异步执行, 并捕获错误
func TryGo(funcT func()) {
	go func() {
		defer RecoverDebugStackS()
		funcT()
	}()
}

// RecoverDebugStackS 通用的错误捕获
func RecoverDebugStackS() {
	if r := recover(); r != nil {
		debugStackS := string(debug.Stack())
		fmt.Println("DefaultRecover defer recover, debug stack info: ", debugStackS)
	}
}
